package com.young.springdemo.AsyncService;

import com.young.springdemo.service.annotation.HandleParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class StudentServiceAsync {


    @HandleParam(notNull = true,notBlank = true)
    public Object getTest(String name,String age,String sex) {
        System.out.println(name+age+sex);
        return "success";
    }

    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Async("myTask")
    public void getStu() {
        try {
            logger.info("老师:开始异步");
            Thread.sleep(1000);
            logger.info("老师:异步结束,执行成功");
        }catch (Exception e){
            logger.error("老师:执行异常");
        }
     }
    @Async
    public void getStudent() {
        try {
            logger.info("学生:开始异步");
            Thread.sleep(1000);
            logger.info("学生:异步结束,执行成功");
        }catch (Exception e){
            logger.error("学生:执行异常");
        }
    }
}
